import * as mongoose from 'mongoose';

const AuthorSchema = new mongoose.Schema({
  name: String,
});

AuthorSchema.virtual('articles', {
  ref: 'Article',
  localField: '_id',
  foreignField: 'author',
  justOne: false,
});

AuthorSchema.set('toObject', { getters: true, virtuals: true });
AuthorSchema.set('toJSON', { getters: true, virtuals: true });

// module.exports = {AuthorSchema}
export { AuthorSchema };
